import javax.swing.JOptionPane;


/*This is class file for the Instruction Set Simulator for SIMD approach.
 * This class defines main instructions each CFU can perform*/  

/*The following instructions are used in this architecture. There is a method
 * for each instruction which takes some arguments and returns output; These 
 * will be mostly registers.
 * 
 * 1- ADD - Addition of two 16 bits data 
 * 2- MAC - Multiply and accumulation (MAC) in single cycle; We have only used 
 * 			MAC unit instead of multiply unit to  
 * 3- SLL - Shift Left Logical
 * 4- SRL - Shift Right Logical
 * 5- NOP - No Operation
 * 6- ADM - Addition and multiplication (ADM) in single cycle, not that the order
 * 			of operation is reverse than MAC instruction. 
 * */



public class cfu {

	/*Registers; There are four 16 bits registers in each CFU
	 * Two register to hold the input data to process
	 * Two registers to hold the output data because size of the 
	 * output data may be larger than the input data
	 * 
	 * */
	
	public static int[] register =  new int[4];
	
	

	
	//Method of NOP operation
	public static void nop(int in_reg_index_1,int in_reg_index_2,int out_reg_index)
	{
		
		register[out_reg_index] = register[in_reg_index_1] * register[in_reg_index_2];  
		
	}
	
	//Method of Addition operation
	public static void add(int in_reg_index_1,int in_reg_index_2,int out_reg_index)
	{
		
		register[out_reg_index] = register[in_reg_index_1] * register[in_reg_index_2];  
		
	}
	
	//Method of SLL (Shift Left Logical) operation
	public static void sll(int in_reg_index_1,int in_reg_index_2,int out_reg_index)
	{
		
		register[out_reg_index] = register[in_reg_index_1] * register[in_reg_index_2];  
		
	}
	
	//Method of SRL (Shift Right Logical) operation
	public static void srl(int in_reg_index_1,int in_reg_index_2,int out_reg_index)
	{
		
		register[out_reg_index] = register[in_reg_index_1] * register[in_reg_index_2];  
		
	}
	
	//Method of MAC (Multiply Accumulate) operation
	public static void mac(int in_reg_index_1,int in_reg_index_2,int out_reg_index)
	{
		
		register[out_reg_index] = register[in_reg_index_1] * register[in_reg_index_2];  
		
	}
	
	//Method of ADM (Addition Multiply) operation
	public static void adm(int in_reg_index_1,int in_reg_index_2,int out_reg_index)
	{
		
		register[out_reg_index] = register[in_reg_index_1] * register[in_reg_index_2];  
		
	}
	
	
	
	//Multiplication method
	
	
	public static void main(String[] args)
	{
		
		/*Decoding Logic*/
		int instr = Integer.parseInt(args[1]);
		
		switch (instr)
		{
		
		// This is NOP operation
		case 0:
			
			
			break;
			
		//This is Addition operation
		case 1:
			
			/* Argument order - input register 1 index,
			 * input register 2 index, 
			 * output register index
			 * */
			add(0,1,4);
			
			break;
			
		//This is MAC operation	
		case 2:
			
			break;
			
		//This is Shift Left logical operation
		case 3:
			break;
			
		//This is Shift right logical operation
		case 4:
			break;
			
		//This is ADM (Addition and multiplication) operation
		case 5:
			break;
		
		default: JOptionPane.showMessageDialog(null, "The operation to CFU is not valid");
		
	
	
		}
	
	}
	
	
	
	
}
